<!doctype html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:yh="http://www.thymeleaf.org">
<head th:replace="themes/yqq/header::resources('个人博客日记','')"></head>

<style>

em {
    color: red;
    font-style: normal;
    font-weight: bold;
}

</style>

<body>
<form th:action="@{/search}" id="searchForm" method="post" target="_BLANK">
		<input type="hidden" name="keyword" id="keywordInput"/>
		<input type="hidden" name="type" id="typeInput"/>
		<input type="hidden" name="categories" id="categoriesInput"/>
		<input type="hidden" name="tags" id="tagsInput"/>
	</form>
<!--top begin-->
<div th:replace="themes/yqq/header::top"></div>
<!--top end-->
<article> 
  <!--lbox begin-->
  <div class="lbox" style="width:100%">
    <div class="whitebg lanmu"> <img th:src="@{/yqq/images/lm01.jpg}">
      <h1>关键字搜索<c th:utext="${'['+type+']'}"></c></h1>
      
      <div th:if="${(searchCategories!=null&&searchCategories!='') || (searchTags!=null&&searchTags!='')}">搜索条件：<c th:if="${searchCategories!=null && searchCategories!=''}">【分类：<c th:utext="${searchCategories}"></c>】</c><c th:if="${searchTags!=null && searchTags!=''}">【标签：<c th:utext="${searchTags}"></c>】</c></div>
      
      <p th:if="${allHits>0}">关键字&nbsp;&nbsp;【<c th:utext="${keyword}"></c>】&nbsp;&nbsp;共搜索到&nbsp;<c th:utext="${allHits}"></c>&nbsp;条数据，这里仅仅显示最符合条件的前<d th:text="${limit}"></d>条。</p>
      <p th:if="${allHits==0}">关键字&nbsp;&nbsp;【<c th:utext="${keyword}"></c>】&nbsp;&nbsp;未搜索到相关数据，请重新输入关键字。</p>
      <div th:if="${allHits==0}" id="noHits" style="display: inline-block;"></div>
    </div>
    <div class="whitebg bloglist">
      <h2 class="htitle">最新博文</h2>
      <ul id="searchList">
        <!--单图-->
        <li th:each="a,loopStatus:${articles}">
          <h3 class="blogtitle"><a th:href="'javascript:openArticle('+${a.cid}+')'"><span th:utext="${'【'+a.categories+'】'+a.title}"></span></a></h3>
<!--           <span class="blogpic imgscale" th:if="${isMobile==false}"><i><a href="javascript:return false;" th:utext="${a.categories}">原创模板</a></i><a th:href="'/article/'+${a.cid}+'?from=search&keyword='+${keyword}+'&matchType='+${matchType}" title=""><img th:src="${a.cover}" alt=""></a></span> -->
          <p class="blogtext" th:utext="${a.contentText}">这些开源的博客程序源码，都是经过很多次版本测试的，都有固定的使用人群。我所知道的主流的博客程序有，Z-blog，Emlog，WordPress，Typecho等，免费的cms系统有，织梦cms（dedecms），phpcms，帝国cms（EmpireCMS）！... </p>
          <p class="bloginfo"><i class="avatar"><img th:src="@{/yqq/images/avatar.jpg}"></i><span th:text="${siteInfo.site_nickname}">张念祥</span><span th:utext="${commons.fmtdate(a.created, 'yyyy-MM-dd')}">2018-10-28</span>【<span th:if="${(a.tags==null||a.tags=='')}">无标签</span><d th:utext="${a.tags}"></d>】</p>
          
          <a th:if="${session.login_user!=null && session.login_user.username=='admin'}" target="_BLANK" th:href="@{'/admin/article/'+${a.cid}}" style="display: block;right: 100px;bottom: 20px;position: absolute;padding: 3px 10px;background: #12b7de;color: #fff;border-radius: 3px;">编辑</a>
          
          <a th:href="'javascript:openArticle('+${a.cid}+')'" class="viewmore">阅读更多</a> </li>
        <li>
      </ul>
      
    </div>
    
    <!--bloglist end--> 
  </div>
</article>
<div th:replace="themes/yqq/header::footer"></div>
</body>

<script th:inline="javascript">

var keyword = [[${keyword}]];
var allHits = [[${allHits}]];
var type = [[${type}]];
var categories = [[${searchCategories}]];
var tags = [[${searchTags}]];
var keywordAnalyze = [[${allHits==0?keywordAnalyze:''}]];
var html2 = "<font color='red'>2、建议搜索单个关键字：</font>";
if(allHits==0 && keywordAnalyze.length>0){
	var spacek = ""
	for(var i=0;i<keywordAnalyze.length;i++){
		var k = keywordAnalyze[i];
		spacek+=k;
		html2 += "<a style='background: #E6E6FA;padding:2px 6px; border-radius:3px;' href='javascript:searchK(\""+k+"\")'>"+k+"</a>"; 
		if(i<(keywordAnalyze.length-1)){
			spacek+=" ";
			html2+="，";
		}
	}
	var html1 = "<font color='red'>1、建议使用空格隔开多个关键字：</font><a href='javascript:searchK(\""+spacek+"\")' style='background: #E6E6FA;padding:2px 6px; border-radius:3px;'>"+spacek+"</a>";
	html1 = "<div>"+html1+"&nbsp;&nbsp;<div style='display: inline-block;margin-left:10px'><img src='https://www.easyicon.net/api/resizeApi.php?id=1214769&amp;size=16' style='display: inline-block;vertical-align:middle;float: inherit;height: 16px;margin-right:0px'><sub>点击搜索</sub></div></div>";
	
	html2 = "<div style='margin-top:5px'>"+html2+"&nbsp;&nbsp;<div style='display: inline-block;margin-left:10px'><img src='https://www.easyicon.net/api/resizeApi.php?id=1214769&amp;size=16' style='display: inline-block;vertical-align:middle;float: inherit;height: 16px;margin-right:0px'><sub>点击搜索</sub></div></div>";
	
	$("#noHits").append(html1);
	$("#noHits").append(html2);
}
function searchK(keyword){
	$("#keywordInput").val(keyword);
	$("#typeInput").val(type);
	if(categories!=null&&categories!=""){$("#categoriesInput").val(categories);}
	if(tags!=null&&tags!=""){$("#tagsInput").val(tags);}
	$("#searchForm").submit();
}


var lastLI = $("#searchList li:last").html();
lastLI = $.trim(lastLI);
if(lastLI==null||lastLI==''){
	$("#searchList li:last").remove();
}

function openArticle(id){
	var url = ctxPath+"article/"+id;
	
	var form = $("<form id='form"+id+"' action='"+url+"' method='post' target='_blank'></form>")
    form.append("<input type='hidden' name='from' value='search'>");
	form.append("<input type='hidden' name='keyword' value='"+[[${keyword}]]+"'>");
	form.append("<input type='hidden' name='matchType' value='"+[[${matchType}]]+"'>");
    $(document.body).append(form);
    form.submit();
}
</script>
<div th:replace="themes/yqq/header::trans"></div>
</html>